package com.sanhuo.idms.dao.provider;

import com.sanhuo.idms.bo.DormHighSearchBO;
import com.sanhuo.triild.provider.SQL;
import com.sanhuo.utils.basic.StringUtil;


public class DormProvider extends SQL {

    public String listAll(DormHighSearchBO bo) {
        SQL sql = getSQL();
        sql.select("d.id id ,t.num tungNum,t.id tungId,r.num roomNum,r.id,roomId ").from("dorm d,tung t,room r")
                .where("d.roomId = r.id and d.tungId = t.id");
        if (StringUtil.isNotBlank(bo.getRoomNum())) {
            sql.where(" r.num = #{roomNum}");
        }
        if (StringUtil.isNotBlank(bo.getTungNum())) {
            sql.where(" t.num = #{tungNum}");
        }
        sql.orderBy("tungNum asc,roomNum", "asc");
        return sql.build();
    }

}
